package Project1;
import java.util.Scanner;
public class MyInfo {
    private String name;
    private String info;
    private String collection;
    private String address;

    private String footPrint;
    private String common;
    private String trade;

    private String goodsName;

    private float pocket;
    private float ticket;
    private float wallet;
    private float flash;

    private void setName(String name)
    {
        this.name=name;
    }
    private void setInfo(String info)
    {
        this.info=info;
    }
    private void setCollection(String collection)
    {
        this.collection=collection;
    }
    private void setAddress(String add)
    {
        this.address=add;
    }
    private void showInfo()//展示信息
    {
        System.out.println("姓名："+name);
        System.out.println("信息："+info);
        System.out.println("收藏："+collection);
        System.out.println("地址："+address);
        System.out.println(footPrint);
        System.out.println(common);
        System.out.println(trade);
        System.out.println("钱包："+wallet);
        System.out.println("红包："+pocket);
        System.out.println("代金券："+ticket);
        System.out.println("闪付："+flash);
    }
    private void moneyInit()//资金初始化
    {
        this.pocket=0;
        this.ticket=0;
        this.wallet=100;
        this.flash=0;
    }
    private void tradeInit()//交易信息初始化
    {
        this.footPrint="足迹：";
        this.common="评价：";
        this.trade="交易记录：";
    }
    private void collect(String name)//加入收藏单
    {
        if(this.collection.equals("无"))
            this.setCollection(" ");
        this.collection+="  "+name;
    }
    private void buyGoods(String name,float price,int amount)//购买产品
    {
        if(this.wallet>=price*amount) {
            this.goodsName = name;
            this.footPrint += "买过" + name + "  ";
            this.wallet -= price * amount;
            this.trade += "买过" + name + amount + "份,总共 ￥" + price * amount+"\n";
            this.collect(name);
            System.out.println("是否评价？  yes or no  ？");
            Scanner ch = new Scanner(System.in);
            Scanner co = new Scanner(System.in);
            String choose = ch.nextLine();
            if (choose.equals("yes")) {//做出评价
                System.out.println("请输入您对" + this.goodsName + "的评价");
                this.goodsCommon(this.goodsName,  co.nextLine());
            }
        }
        else System.out.println("不好意思，资金不够，购买失败");
    }
    private void goodsCommon(String name,String common)//评价产品信息
    {
        this.common+="产品"+name+common+"\n";
        this.footPrint+="评价过"+name+"  ";
    }

    public static void main(String[] args) {
        MyInfo Yu=new MyInfo();
        Scanner sc1 = new Scanner(System.in);
        Scanner sc2 = new Scanner(System.in);
        Scanner sc3 = new Scanner(System.in);
        Scanner sc4 = new Scanner(System.in);

        System.out.println("请输入您的姓名");
        Yu.setName(sc1.nextLine());
        System.out.println("请输入您的信息");
        Yu.setInfo(sc2.nextLine()) ;
        System.out.println("请输入您的地址");
        Yu.setAddress(sc3.nextLine());
        System.out.println("请输入您的收藏");
        Yu.setCollection(sc4.nextLine());
        Yu.moneyInit();
        Yu.tradeInit();
        System.out.println("您的基本信息：");
        Yu.showInfo();
        Scanner pro = new Scanner(System.in);
        System.out.println("是否购买商品？  buy or not ？");
        String process = pro.nextLine();
        while(process.equals("buy")&&Yu.wallet>0) {//购买商品
            Scanner s1 = new Scanner(System.in);
            Scanner s2 = new Scanner(System.in);
            Scanner s3 = new Scanner(System.in);
            System.out.print("请输入要购买的商品名称");
            String name = s1.nextLine();
            System.out.print("价格");
            float price = s2.nextFloat();
            System.out.print("数量");
            int amount = s3.nextInt();
            Yu.buyGoods(name, price, amount);
            if(Yu.wallet<=5) {
                System.out.println("您的钱包钱过少了，是否充值？ yes or not");
                Scanner ins = new Scanner(System.in);
                String invest=ins.nextLine();
                if(invest.equals("yes")){
                    System.out.println("充值多少元？");
                    float mon=pro.nextFloat();
                    Yu.wallet+=mon;
                }
                else break;
            }
            System.out.println("是否继续购买商品？  buy or not ？");
            Scanner sd = new Scanner(System.in);
            process = sd.nextLine();
        }
        System.out.println("您的最终信息");
        Yu.showInfo();
    }

}
